/*
 * Timer
 */

var timer = {
	skipPositionUpdates : false,
	timer : null,
	start : function() {
		debug.print("timer.start");
		this.timer = setInterval(timer.trigger, config.timerInterval);
	},
	stop : function() {
		debug.print("timer.stop");
		clearInterval(this.timer);
	},
	trigger : function() {		
		// in order to hide debug msgs
		config.timerExecuting = true;
		// now display debug message
		debug.print("timer.trigger", true);
		// update buffer
		player[0].updateBufferStatus();
		player[1].updateBufferStatus();
		// update time
		player[0].updateTime();
		player[1].updateTime();
		// update autodj controls
		ui.updateAutodjControls();
		// display position
		// if user is seeking in video, don't update position
		if (timer.skipPositionUpdates !== true) {
			player[0].updatePositionStatus();
			player[1].updatePositionStatus();
		}		
		// autoplay check
		autoplay.check();
		// autodj check
		autodj.check();
		// display debug msgs
		config.timerExecuting = false;
	}
}